package com.example.myapplication

import com.example.myapplication.realtime.UserPermissions

/**
 * 用户会话管理
 */
object UserSession {
    var currentUser: User? = null
    var userPermissions: UserPermissions? = null
    
    fun isLoggedIn(): Boolean {
        return currentUser != null
    }
    
    fun canAddPatients(): Boolean {
        return userPermissions?.canAddPatients ?: false
    }
    
    fun canViewAllPatients(): Boolean {
        return userPermissions?.canViewAllPatients ?: false
    }
    
    fun canViewDepartmentPatients(): Boolean {
        return userPermissions?.canViewDepartmentPatients ?: false
    }
    
    fun canApproveUsers(): Boolean {
        return userPermissions?.canApproveUsers ?: false
    }
    
    fun getUserType(): UserType? {
        return currentUser?.userType
    }
    
    fun getDepartment(): String? {
        return currentUser?.department
    }
    
    fun getUserId(): Long? {
        return currentUser?.id
    }
    
    fun getRealName(): String? {
        return currentUser?.realName
    }
    
    fun logout() {
        currentUser = null
        userPermissions = null
    }
}
